// pages/gr_xx/gr_xx.js
const app = getApp()
Page({
  /**
   * 页面的初始数据
   */
  data: {
    
  },
  /**
   * 生命周期函数--监听页面加载
   */
  hb_sjh:function(e){
      wx.navigateTo({
        url: '../hb_sjh/hb_sjh',
      })
  },
  bd_yx:function(e){
    wx.navigateTo({
      url: '../bd_yx/bd_yx',
    })
},
jieban:function(){
   var that = this;

   that.setData({
    yc_s:"display:block"
   })
},
zhidao:function(){
  var that = this;
  that.setData({
   yc_s:"display:none"
  })
},
zhidao1:function(){
  var that = this;
    wx.request({
        url: app.globalData.url_l + 'api/member/mem_guanli', //注意改成自己的服务器请求地址哦！
        method: 'POST',
        data:{
          uid:app.globalData.uid,
          state:2
        },
        header: {
          'content-type': 'application/x-www-form-urlencoded;charset=utf-8',
        },
        success: function (res) {
           console.log(res)
           if(res.data.code==1){
            wx.showToast({
              title: '解绑成功',
              icon: 'none',
              duration: 2000
            })
           }else if(res.data.code==2){
            wx.showToast({
              title: '解绑失败',
              icon: 'none',
              duration: 2000
            })
           }else if(res.data.code==3){
            wx.showToast({
              title: '会员状态不正确',
              icon: 'none',
              duration: 2000
            })
           }
        }
      })
  that.setData({
   yc_s:"display:none"
  })
},
  onLoad: function (options) {
      var that = this;
      wx.request({
        url: app.globalData.url_l + 'api/member/index',
        method: 'post',
        data:{
            uid:app.globalData.uid,
        },
        header: {
          'content-type': 'application/x-www-form-urlencoded'
        },
        success: function (res) {
          console.log(res)
          if(res.data.data.name==''||res.data.data.name=='null'||res.data.data.name==undefined){
            wx.showModal({
              title: '温馨提示',
              content: '您还没有实名认证，是否要去认证？',
              success (res) {
                if (res.confirm) {
                  wx.navigateTo({
                    url: '../shimingrenzheng/shimingrenzheng',
                  })
                } else if (res.cancel) {
                  console.log('用户点击取消')
                }
              }
            })
          }else if(res.data.data.idnum==''||res.data.data.idnum=='null'||res.data.data.idnum==undefined){
            wx.showModal({
              title: '温馨提示',
              content: '您还没有实名认证，是否要去认证？',
              success (res) {
                if (res.confirm) {
                  wx.navigateTo({
                    url: '../shimingrenzheng/shimingrenzheng',
                  })
                } else if (res.cancel) {
                  console.log('用户点击取消')
                }
              }
            })
          }
           if(res.data.code==1){
            app.globalData.corpid = res.data.data.corpid
             that.setData({
               ge_xx:res.data.data
             })
           }else{
            that.setData({
              ge_xx:''
            })
           }
        }
      })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    var that = this;
    wx.request({
      url: app.globalData.url_l + 'api/member/index',
      method: 'post',
      data:{
          uid:app.globalData.uid,
      },
      header: {
        'content-type': 'application/x-www-form-urlencoded'
      },
      success: function (res) {
        console.log(res)
         if(res.data.code==1){
          app.globalData.corpid = res.data.data.corpid
           that.setData({
             ge_xx:res.data.data
           })
         }else{
          that.setData({
            ge_xx:''
          })
         }
      }
    })
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})